package xx.boot.swagger.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import xx.boot.swagger.entity.User;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api")
@Api(tags = "用户管理")
public class UserController {

    @GetMapping("/users")
    @ApiOperation("获取用户列表")
    public List<User> getUsers() {
        List<User> users = new ArrayList<>();
        users.add(new User(1, "张三", 20));
        users.add(new User(2, "李四", 25));
        users.add(new User(3, "王五", 30));
        return users;
    }

    @PostMapping("/users")
    @ApiOperation("添加用户")
    public User addUser(@RequestBody User user) {
        return user;
    }
}
